home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performCreateSubcharacter.me < prev    next >
Encoding:
Text File  |  2003-07-17  |  13.2 KB  |  489 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  Oct 15, 1998
  22. //
  23. //  Description:
  24. //      This script is the create subCharacter option box dialogs.
  25. //
  26. //  Input Arguments:
  27. //      None.
  28. //
  29. //  Return Value:
  30. //      None.
  31. //
  32.  
  33. proc setOptionVars (int $forceFactorySettings)
  34. {
  35.     // SubCharacter name
  36.     //
  37.     if ($forceFactorySettings || !`optionVar -exists createSubCharacterName`) {
  38.         optionVar -stringValue createSubCharacterName "subCharacter1";
  39.     }
  40.  
  41.  
  42.     if ($forceFactorySettings || !`optionVar -exists subCharacterKeysToUse`) {
  43.         optionVar -intValue subCharacterKeysToUse 2;
  44.     }
  45.  
  46.     // Which attrs to add to subCharacter
  47.     //
  48.     if ($forceFactorySettings || !`optionVar -exists subCharacterExcTranslate`) {
  49.         // exclude translate
  50.         optionVar -intValue subCharacterExcTranslate 0;
  51.     }
  52.     if ($forceFactorySettings || !`optionVar -exists subCharacterExcRotate`) {
  53.         // exclude rotate
  54.         optionVar -intValue subCharacterExcRotate 0;
  55.     }
  56.     if ($forceFactorySettings || !`optionVar -exists subCharacterExcScale`) {
  57.         // exclude scale
  58.         optionVar -intValue subCharacterExcScale 1;
  59.     }
  60.     if ($forceFactorySettings || !`optionVar -exists subCharacterExcVis`) {
  61.         // exclude visibility
  62.         optionVar -intValue subCharacterExcVis 1;
  63.     }
  64.     if ($forceFactorySettings || !`optionVar -exists subCharacterExcDyn`) {
  65.         // exclude dynamic
  66.         optionVar -intValue subCharacterExcDyn 0;
  67.     }
  68. }
  69.  
  70. //
  71. //  Procedure Name:
  72. //      createSubCharacterSetup
  73. //
  74. //  Description:
  75. //        Update the state of the option box UI to reflect the option values.
  76. //
  77. //  Input Arguments:
  78. //      parent               - Top level parent layout of the option box UI.
  79. //                             Required so that UI object names can be 
  80. //                             successfully resolved.
  81. //
  82. //    forceFactorySettings     - Whether the option values should be set to
  83. //                             default values.
  84. //
  85. //  Return Value:
  86. //      None.
  87. //
  88. global proc createSubCharacterSetup (string $parent, int $forceFactorySettings)
  89. {
  90.     // Retrieve the option settings
  91.     //
  92.     setOptionVars( $forceFactorySettings );
  93.  
  94.     setParent $parent;
  95.     
  96.     // name
  97.     //
  98.     string $name = `optionVar -query createSubCharacterName`;
  99.     textFieldGrp -e -text $name subCharacterNameWidget;
  100.  
  101.     int $exc_t = `optionVar -query subCharacterExcTranslate`;
  102.     checkBoxGrp -edit -value1 $exc_t excludeTranslateWidget;
  103.     int $exc_r = `optionVar -query subCharacterExcRotate`;
  104.     checkBoxGrp -edit -value1 $exc_r excludeRotateWidget;
  105.     int $exc_s = `optionVar -query subCharacterExcScale`;
  106.     checkBoxGrp -edit -value1 $exc_s excludeScaleWidget;
  107.     int $exc_v = `optionVar -query subCharacterExcVis`;
  108.     checkBoxGrp -edit -value1 $exc_v excludeVisWidget;
  109.     int $exc_d = `optionVar -query subCharacterExcDyn`;
  110.     checkBoxGrp -edit -value1 $exc_d excludeDynWidget;
  111.  
  112.     int $exc_total = $exc_t + $exc_r + $exc_s + $exc_v + $exc_d;
  113.  
  114.     int $keysToUse = `optionVar -q subCharacterKeysToUse`;
  115.     if ($keysToUse == 0) 
  116.         radioButtonGrp -edit -select 1 subCharacterKeysWidget;
  117.     else if ($keysToUse == 1) 
  118.         radioButtonGrp -edit -select 1 charChannelRB;
  119.     else
  120.         radioButtonGrp -edit -select 1 charExceptRB;
  121.  
  122.     if (0 == $exc_total) {
  123.         radioButtonGrp -e -sl 1 subCharacterKeysWidget;
  124.         $keysToUse = 0;
  125.     }
  126.         
  127.     if ($keysToUse != 2) {
  128.         checkBoxGrp -edit -enable 0 excludeTranslateWidget;
  129.         checkBoxGrp -edit -enable 0 excludeRotateWidget;
  130.         checkBoxGrp -edit -enable 0 excludeScaleWidget;
  131.         checkBoxGrp -edit -enable 0 excludeDynWidget;
  132.         checkBoxGrp -edit -enable 0 excludeVisWidget;
  133.     } else {
  134.         checkBoxGrp -edit -enable 1 excludeTranslateWidget;
  135.         checkBoxGrp -edit -enable 1 excludeRotateWidget;
  136.         checkBoxGrp -edit -enable 1 excludeScaleWidget;
  137.         checkBoxGrp -edit -enable 1 excludeDynWidget;
  138.         checkBoxGrp -edit -enable 1 excludeVisWidget;
  139.     }
  140.     
  141. }
  142.  
  143. //
  144. //  Procedure Name:
  145. //      createSubCharacterCallback
  146. //
  147. //  Description:
  148. //        Update the option values with the current state of the option box UI.
  149. //
  150. //  Input Arguments:
  151. //      parent - Top level parent layout of the option box UI.  Required so
  152. //               that UI object names can be successfully resolved.
  153. //
  154. //    doIt       - Whether the command should execute.
  155. //
  156. //  Return Value:
  157. //      None.
  158. //
  159. global proc createSubCharacterCallback (string $parent, int $doIt)
  160. {
  161.     setParent $parent;
  162.  
  163.     // Name
  164.     //
  165.     optionVar -stringValue createSubCharacterName
  166.         `textFieldGrp -q -text subCharacterNameWidget`;
  167.  
  168.     int $keysToUse = `radioButtonGrp -q -sl subCharacterKeysWidget`;
  169.     int $channel = `radioButtonGrp -q -sl charChannelRB`;
  170.     if ($keysToUse) {
  171.         optionVar -intValue subCharacterKeysToUse 0;
  172.     } else if ($channel) {
  173.         optionVar -intValue subCharacterKeysToUse 1;        
  174.     } else {
  175.         optionVar -intValue subCharacterKeysToUse 2;
  176.     }
  177.  
  178.     // which attrs to exclude in the subCharacter
  179.     //
  180.     optionVar -intValue subCharacterExcTranslate
  181.         `checkBoxGrp -q -value1 excludeTranslateWidget`;
  182.     optionVar -intValue subCharacterExcRotate
  183.         `checkBoxGrp -q -value1 excludeRotateWidget`;
  184.     optionVar -intValue subCharacterExcScale
  185.         `checkBoxGrp -q -value1 excludeScaleWidget`;
  186.     optionVar -intValue subCharacterExcVis
  187.         `checkBoxGrp -q -value1 excludeVisWidget`;
  188.     optionVar -intValue subCharacterExcDyn
  189.         `checkBoxGrp -q -value1 excludeDynWidget`;
  190.     
  191.     if ($doIt)
  192.     {    
  193.         performCreateSubcharacter false; 
  194.         addToRecentCommandQueue "performCreateSubcharacter false" "CreateSubCharacter";
  195.     }
  196. }
  197.  
  198. global proc subcharAllKeyableOnCB()
  199. {
  200.     checkBoxGrp -edit -enable 0 excludeTranslateWidget;
  201.     checkBoxGrp -edit -enable 0 excludeRotateWidget;
  202.     checkBoxGrp -edit -enable 0 excludeScaleWidget;
  203.     checkBoxGrp -edit -enable 0 excludeVisWidget;    
  204.     checkBoxGrp -edit -enable 0 excludeDynWidget;
  205. }
  206.  
  207. global proc subcharAllKeyableOffCB()
  208. {
  209.     checkBoxGrp -edit -enable 1 excludeTranslateWidget;
  210.     checkBoxGrp -edit -enable 1 excludeRotateWidget;
  211.     checkBoxGrp -edit -enable 1 excludeScaleWidget;
  212.     checkBoxGrp -edit -enable 1 excludeVisWidget;    
  213.     checkBoxGrp -edit -enable 1 excludeDynWidget;
  214. }
  215.  
  216. global proc updateSubCharWidgetsCB()
  217. {
  218.     int $exc_t = `checkBoxGrp -q -value1 excludeTranslateWidget`;
  219.     int $exc_r = `checkBoxGrp -q -value1 excludeRotateWidget`;
  220.     int $exc_s = `checkBoxGrp -q -value1 excludeScaleWidget`;
  221.     int $exc_v = `checkBoxGrp -q -value1 excludeVisWidget`;
  222.     int $exc_d = `checkBoxGrp -q -value1 excludeDynWidget`;
  223.     int $exc_total = $exc_t + $exc_r + $exc_s + $exc_v + $exc_d;
  224.  
  225.     if (0 == $exc_total) {
  226.         radioButtonGrp -e -sl 1 subCharacterKeysWidget;
  227.     }
  228. }
  229.  
  230.  
  231. proc string createSubCharacterWidgets( string $parent )
  232. {
  233.     setParent $parent;
  234.     
  235.     string $tabForm = `columnLayout -adjustableColumn true`;
  236.  
  237.     textFieldGrp -label "Name" -text "subCharacter1" subCharacterNameWidget;
  238.  
  239.     radioButtonGrp -numberOfRadioButtons 1
  240.         -label "Subcharacter Set Attributes"
  241.         -label1 "All Keyable"
  242.         -onc subcharAllKeyableOnCB
  243.         subCharacterKeysWidget;
  244.     
  245.     radioButtonGrp -numberOfRadioButtons 1
  246.         -label1 "From Channel Box"
  247.         -shareCollection subCharacterKeysWidget
  248.         -onc subcharAllKeyableOnCB        
  249.         charChannelRB;
  250.  
  251.     radioButtonGrp -numberOfRadioButtons 1
  252.         -label1 "All Keyable Except:"
  253.         -shareCollection subCharacterKeysWidget
  254.         -onc subcharAllKeyableOffCB        
  255.         charExceptRB;
  256.     
  257.     // which attributes to exclude in subCharacter
  258.     checkBoxGrp
  259.         -label ""
  260.         -label1 "No Translate"
  261.         -numberOfCheckBoxes 1
  262.         -ofc updateSubCharWidgetsCB        
  263.         excludeTranslateWidget;
  264.     checkBoxGrp
  265.         -label ""
  266.         -label1 "No Rotate"
  267.         -numberOfCheckBoxes 1
  268.         -ofc updateSubCharWidgetsCB        
  269.         excludeRotateWidget;
  270.     checkBoxGrp
  271.         -label ""
  272.         -label1 "No Scale"
  273.         -numberOfCheckBoxes 1
  274.         -ofc updateSubCharWidgetsCB        
  275.         excludeScaleWidget;
  276.     checkBoxGrp
  277.         -label ""
  278.         -label1 "No Visibility"
  279.         -numberOfCheckBoxes 1
  280.         -ofc updateSubCharWidgetsCB        
  281.         excludeVisWidget;
  282.     checkBoxGrp
  283.         -label ""
  284.         -label1 "No Dynamic"
  285.         -numberOfCheckBoxes 1
  286.         -ofc updateSubCharWidgetsCB        
  287.         excludeDynWidget;
  288.     
  289.     return $tabForm;
  290. }
  291.  
  292. global proc createSubCharacterOptions ()
  293. {
  294.     string $commandName = "createSubCharacter";
  295.  
  296.     string $applyTitle = "Create";
  297.     
  298.     // Build the option box "methods"
  299.     //
  300.     string $callback = ($commandName + "Callback");
  301.     string $setup = ($commandName + "Setup");
  302.  
  303.     //    Get the option box.
  304.     //
  305.     //  The value returned is the name of the layout to be used as
  306.     //    the parent for the option box UI.
  307.     //
  308.     string $layout = getOptionBox();
  309.     setParent $layout;
  310.  
  311.     setOptionBoxCommandName("character");
  312.  
  313.     setUITemplate -pushTemplate DefaultTemplate;
  314.     waitCursor -state 1;
  315.     tabLayout -scr true -tv false;    // To get the scroll bars
  316.  
  317.     string $parent = `columnLayout -adjustableColumn 1`;
  318.  
  319.     createSubCharacterWidgets $parent;
  320.  
  321.     waitCursor -state 0;
  322.     setUITemplate -popTemplate;
  323.  
  324.     //    'Apply' button.
  325.     //
  326.     string $applyBtn = getOptionBoxApplyBtn();
  327.     button -edit
  328.         -label "Create Subcharacter Set"
  329.         -command ($callback + " " + $parent + " " + 1)
  330.         $applyBtn;
  331.  
  332.     //    'Save' button.
  333.     //
  334.     string $saveBtn = getOptionBoxSaveBtn();
  335.     button -edit 
  336.         -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
  337.         $saveBtn;
  338.  
  339.     //    'Reset' button.
  340.     //
  341.     string $resetBtn = getOptionBoxResetBtn();
  342.     button -edit 
  343.         -command ($setup + " " + $parent + " " + 1)
  344.         $resetBtn;
  345.  
  346.     //    Set the option box title.
  347.     //
  348.     setOptionBoxTitle("Create Subcharacter Set Options");
  349.  
  350.     //    Customize the 'Help' menu item text.
  351.     //
  352.     setOptionBoxHelpTag( "CreateSubcharacter" );
  353.  
  354.     //    Set the current values of the option box.
  355.     //
  356.     eval (($setup + " " + $parent + " " + 0));    
  357.     
  358.     //    Show the option box.
  359.     //
  360.     showOptionBox();
  361. }
  362.  
  363.  
  364. //
  365. //  Procedure Name:
  366. //      assembleCmd
  367. //
  368. //  Description:
  369. //        Construct the command that will apply the option box values.
  370. //
  371. //  Input Arguments:
  372. //      None.
  373. //
  374. //  Return Value:
  375. //      None.
  376. //
  377. proc string assembleCmd()
  378. {
  379.     string $cmd;
  380.  
  381.     setOptionVars(false);
  382.  
  383.     // get the partition name
  384.     string $subCharacterName = "subCharacter1";
  385.     if (`optionVar -exists createSubCharacterName`) {
  386.         $subCharacterName = `optionVar -query createSubCharacterName`;
  387.     }
  388.  
  389.     int $excludeTranslate = 0;
  390.     int $excludeRotate = 0;
  391.     int $excludeScale = 0;
  392.     int $excludeVisibility = 0;
  393.     int $excludeDynamic = 0;
  394.     int $useChannelBox = 0;
  395.  
  396.     if (`optionVar -exists subCharacterKeysToUse`) {
  397.         int $keysToUse = `optionVar -q subCharacterKeysToUse`;
  398.         if ($keysToUse == 2) {
  399.             if (`optionVar -exists subCharacterExcTranslate`) {
  400.                 $excludeTranslate = (`optionVar -query subCharacterExcTranslate`);
  401.             }
  402.             if (`optionVar -exists subCharacterExcRotate`) {
  403.                 $excludeRotate = (`optionVar -query subCharacterExcRotate`);
  404.             }
  405.             if (`optionVar -exists subCharacterExcScale`) {
  406.                 $excludeScale = (`optionVar -query subCharacterExcScale`);
  407.             }
  408.             if (`optionVar -exists subCharacterExcVis`) {
  409.                 $excludeVisibility = (`optionVar -query subCharacterExcVis`);
  410.             }
  411.             if (`optionVar -exists subCharacterExcDyn`) {
  412.                 $excludeDynamic = (`optionVar -query subCharacterExcDyn`);
  413.             }
  414.         } else if ($keysToUse == 1) {
  415.             $useChannelBox = 1;
  416.         }
  417.     }
  418.     
  419.     // doCreateSubCharacterArgList takes a string array 
  420.     //
  421.     $cmd =    "doCreateSubcharacterArgList 2 { " +
  422.         "\"" + $subCharacterName + "\"" +
  423.         ",\"" + $excludeTranslate + "\"" +                
  424.         ",\"" + $excludeRotate + "\"" +                
  425.         ",\"" + $excludeScale + "\"" +                
  426.         ",\"" + $excludeVisibility + "\"" +
  427.         ",\"" + $excludeDynamic + "\"" +
  428.         ",\"" + $useChannelBox + "\"" +                                
  429.         " };";
  430.  
  431.     return $cmd;
  432. }
  433.  
  434. //
  435. //  Procedure Name:
  436. //      performCreateSubcharacter
  437. //
  438. //  Description:
  439. //        Create a subCharacter and add the animatable attributes from the 
  440. //      selected nodes.  This procedure will also show the option box
  441. //        window if necessary as well as construct the command string
  442. //        that will create a subCharacter with the current option box values.
  443. //
  444. //  Input Arguments:
  445. //      0 - Execute the command.
  446. //      1 - Show the option box dialog.
  447. //      2 - Return the command.
  448. //
  449. //  Return Value:
  450. //      None.
  451. //
  452. global proc string
  453. performCreateSubcharacter (int $action)
  454. {
  455.     string $cmd = "";
  456.  
  457.     switch ($action) {
  458.  
  459.         //    Execute the command.
  460.         //
  461.         case 0:
  462.             //    Retrieve the option settings
  463.             //
  464.             setOptionVars(false);
  465.  
  466.             //    Get the command.
  467.             //
  468.             $cmd = `assembleCmd`;
  469.  
  470.             //    Execute the command with the option settings.
  471.             //
  472.             evalEcho($cmd);
  473.  
  474.             break;
  475.  
  476.         //    Show the option box.
  477.         //
  478.         case 1:
  479.             createSubCharacterOptions;
  480.             break;
  481.         case 2:
  482.             //    Get the command.
  483.             //
  484.             $cmd = `assembleCmd`;
  485.     }
  486.     return $cmd;
  487. }
  488.  
  489.